package ntd.util.config.common.bo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@Schema(description = "通用响应对象")
@NoArgsConstructor
public class ResponseBO<T> {

    @Schema(description = "响应code")
    public int code = 200;
    @Schema(description = "响应msg，可能为空")
    public String msg;
    @Schema(description = "响应单个数据对象")
    public T data;
    @Schema(description = "响应列表数据对象")
    public List<T> list;


    public ResponseBO(T data) {
        this.data = data;
    }

    public ResponseBO(List<T> list) {
        this.list = list;
    }

    public ResponseBO(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ResponseBO<String> err(String msg) {
        return new ResponseBO<>(500, msg);
    }
}
